#include"Comm.hpp"
#include "Fifo.hpp"
int main()
{
    //获取共享内存
    int key=GetShmKey();
    std::cout << "key: "<< ToHex(key) << std::endl;
    
    //创建共享内存
    int shmid = CreateShm(key,defaultsize);
    std:: cout<< "shmid: "<< shmid << std::endl;

     char *addr =(char*)ShmAttach(shmid);
    std::cout<<"Attact success"<<std::endl;

    memset(addr, 0, defaultsize);
    Sync syn;
    syn.OpenWriteOrDie();

    // 可以进行通信了
    for (char c = 'A'; c <= 'Z'; c++) // pipe, fifo, ->read/write->系统调用， shm -> 没有使用系统调用！！
    {
        addr[c - 'A'] = c;
        sleep(1);
        syn.Wakeup();
    }
    return 0;
}